#ifndef __GLTEXTURE__
#define __GLTEXTURE__

#include "..\ITexture.h"

#include <cstdint>
#include <string>
#include <istream>
#include <fstream>

#include <wx/stream.h>
#include <wx/wfstream.h>

#ifndef byte
typedef unsigned char byte;
#endif

struct Colorb;

class GLTexture : public ITexture
{
	int _width, _height, _scale;
	uint32_t _id;

	void DeleteIfLoaded();
	void EnsureIL();
	void BlitData(const int &bpp, const int &format, const byte *data);
	void CreateImage();

public:
	const int &GetWidth() const { return _width; }
	const int &GetHeight() const { return _height; }
	const int &GetScale() const { return _scale; }
	const uint32_t &GetID() const { return _id; }
	
	/// <summary>
	/// Sets the scale.
	/// </summary>
	/// <param name="value">The value.</param>
	void SetScale(const int &value) { _scale = value; }

	GLTexture() :
		_width(-1),
		_height(-1),
		_scale(-1),
		_id(0)
	{
	}

	~GLTexture();

	void Load(const byte *data, const int &width, const int &height);
	void Load(wxInputStream &stream);
	void Copy(const ITexture *texture);
	void Delete();
	void BlitData(Colorb *ptr);
};
#endif